package com.liu.design.behavior.strategy.pay;

/**
 * @author LIU
 * @version 1.0
 * @date 2024/5/8 10:43
 * @description 支付渠道
 * 抽象策略类(Strategy):策略的抽象类或接口，给出所需实现接口。
 */
public abstract class Payment {

    public abstract String getName();

    protected abstract double queryBalance(String uid);

    public String pay(String uid , double amount){
        double balance = this.queryBalance(uid);
        if (balance < amount){
            return "支付失败，余额不足，余额：" + balance;
        }

        return "支付成功，支付金额" + amount + "，余额：" + (balance - amount);
    }
}
